<form class="layui-form layui-form-pane" id="suFormInfo">
    <div class="layui-form-item">
        <label class="layui-form-label red-star-label">昵称:</label>
        <div class="layui-input-block">
            <input type="text" name="name" placeholder="请输入昵称" class="layui-input"
                   lay-verType="tips" lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block text-right">
            <button class="layui-btn" lay-filter="suFormSubmitInfo" lay-submit style="width: 150px">保存</button>
        </div>
    </div>
</form>

<script>
    layui.use(['layer', 'form', 'reqApi', 'admin'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var reqApi = layui.reqApi;
        var admin = layui.admin;

        // 监听提交
        form.on('submit(suFormSubmitInfo)', function (obj) {
            var reqEL = layer.msg('操作执行中', {icon: 16, shade: 0.01, time: 6000});
            admin.req({
                url: reqApi.admin.home.updateUserInfo
                , type: 'put'
                , data: obj.field
                , complete: function () {
                    layer.close(reqEL);
                }
                , success: function () {
                    layer.msg('操作成功', {offset: '15px', icon: 1, time: 500},function () {
                        location.reload();
                    });
                }
            });
            return false;
        });
    });
</script>